<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>职位搜索-高级搜索</title>
    <link type="text/css" rel="stylesheet" href="css/searchJob.css"/>
    <script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
    <script type="text/javascript" src="js/searchJob.js"></script>
</head>

<body>
<div class="topDiv">
    <div class="topL">
        <div class="logo">
            <a href="index.jsp">
                <img src="images/LOGO.png"/>
                <img src="images/view_logo40.png" class="img1"/>
            </a>
        </div>
        <img src="images/spirit_40.png"/>
    </div>
    <div class="topR">
        <div class="topR0 topR2"><a href="register.jsp">注册</a></div>
        <div class="topR0 topR3"><a href="login.jsp">个人登录</a></div>
        <div class="clear"></div>
    </div>
</div>
<div class="menuDiv">
    <div class="mainWarp">
    </div>
</div>
<div class="clear"></div>
<div class="menuLittle">
</div>
<div class="clear"></div>
<div class="searchDiv">
    <div class="search1">
        <div class="sea1_1">
            <input id="keywords" value="" type="text" placeholder="请填写关键词或选择职位" class="keyword"/>
            <span class="jiantou"></span>
        </div>
        <div id="jobsearchbox" class="sea1_4">
            <a>搜工作</a>
        </div>
    </div>
</div>
<div class="clear"></div>
<div class="seachlist">
    <div class="listtop">
        <div class="tj1">
            <span class="list">列表</span>
            <span class="zhaoyao">摘要</span>
        </div>
        <div id="headiv" class="tj3">
<%--            <span>共1141条  第1/39页</span>--%>
        </div>
    </div>
    <div class="clear"></div>
    <div class="listcon">
        <table border="0" width="100%" cellpadding="0" cellspacing="0" class="listtab">
            <thead>
            <tr>
                <th width="24%" style="padding-left:17px">职位名称</th>
                <th width="30%">企业名称</th>
                <th width="8%"></th>
                <th width="16%">工作地点</th>
                <th width="8%">薪水</th>
                <th width="10%">刷新时间</th>
            </tr>
            </thead>
            <tbody id="jobInfoList">
            <tr>
                <td>
                    <a href="job_info.html" class="jobname">后勤文员</a>
                </td>
                <td>
                    <div class="company">
                        <a href="company.html">广东同源科技发展有限公司</a>
                    </div>
                </td>
                <td></td>
                <td>广东佛山南海区</td>
                <td><span>2.5K-3.5K</span></td>
                <td>1小时</td>
            </tr>
            <tr class="xxdetail none">
                <td colspan="5">
                    <div class="yaoqiu">学历要求：中专 | 工作经验：1~2年 | 公司规模：少于50人 | 招聘方式：全职<br/>
                        岗位职责：1、 负责公司资产管理、办公用品采购及劳保用品的管理工作,避免公司资产流失和浪费； 2、 负责书刊资料印刷、快递、物流及办公室的其他事情； 3、 ...<br/>
                        岗位要求：1、1年以上行政工作经验； 2、熟悉行政工作流程，办公用品采购流程，企业资产管理； 3、较强的责任心和敬业精神，良好的组织协调能力及沟通能力，较...
                    </div>
                </td>
                <td>
                    <div class="applydiv">
                        <a href="javascript:void(0);" class="ysqbtn">已申请</a>
                        <span class="ygz">已关注</span>
                    </div>
                </td>
            </tr>
            <tr style="background: rgb(247, 248, 250)">
                <td>
                    <a href="job_info.html" class="jobname">国际贸易专员</a>
                </td>
                <td>
                    <div class="company">
                        <a href="company.html">深圳市鼎润轻纺进出口有限公司</a>
                    </div>
                </td>
                <td></td>
                <td>广东深圳福田区</td>
                <td>3.5K-6K</td>
                <td>刚刚</td>
            </tr>
            <tr style="background: rgb(247, 248, 250)" class="xxdetail none">
                <td colspan="5">
                    <div class="yaoqiu">学历要求：中专 | 工作经验：1~2年 | 公司规模：少于50人 | 招聘方式：全职<br/>
                        岗位职责：1、 负责公司资产管理、办公用品采购及劳保用品的管理工作,避免公司资产流失和浪费； 2、 负责书刊资料印刷、快递、物流及办公室的其他事情； 3、 ...<br/>
                        岗位要求：1、1年以上行政工作经验； 2、熟悉行政工作流程，办公用品采购流程，企业资产管理； 3、较强的责任心和敬业精神，良好的组织协调能力及沟通能力，较...
                    </div>
                </td>
                <td>
                    <div class="applydiv">
                        <a href="javascript:void(0);" class="ljsqbtn">立即申请</a>
                        <span>关注</span>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
    <div class="clear"></div>
    <div id="PageNumbeRprompt" class="listbottom">
        <div id="footdiv" class="lb3">
            <span>共1141条  第1/39页</span>
        </div>
    </div>
    <div class="clear"></div>
    <div id="PageBlock" class="fenyediv">

    </div>
    <div class="clear"></div>
</div>
<div class="clear"></div>
<div class="footer">
</div>
</body>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script type="text/javascript">
    var nowpage = 1;
    var keyword = "${param.keyword}";
    var uid = "${user.uid}"

    function diffTime(endDate, startDate) {
        var startDate = new Date(startDate);
        var endDate = new Date(endDate);
        var nd = 1000 * 24 * 60 * 60;
        var nh = 1000 * 60 * 60;
        var nm = 1000 * 60;
        // long ns = 1000;
        // 获得两个时间的毫秒时间差异
        var diff = endDate.getTime() - startDate.getTime();
        // 计算差多少天
        var day = diff / nd;
        // 计算差多少小时
        var hour = diff % nd / nh;
        // 计算差多少分钟
        var min = diff % nd % nh / nm;
        // 计算差多少秒//输出结果
        // long sec = diff % nd % nh % nm / ns;
        if (day >= 1) {
            return day + "天";
        } else if (hour >= 1 && day < 1) {
            return hour + "小时";
        } else {
            return min + "分钟";
        }
    }

    function initpagesearch(PageHelper) {
        $("tbody").empty()
        $("[id='PageBlock']").empty()
        eval("var PageHelper=" + PageHelper);
        for (var i = 0; i < PageHelper.userJobEnterpriseDaoList.length; i++) {
            var jrefreshdate = PageHelper.userJobEnterpriseDaoList[i].job.jrefreshdate;
            var jreleasedate = PageHelper.userJobEnterpriseDaoList[i].job.jreleasedate;
            var difTime = diffTime(jrefreshdate, jreleasedate);
            var obj =
                "<tr>" +
                "<td>" +
                "<a href='getOnejobByJid.do?uid=" + uid + "&jid=" + PageHelper.userJobEnterpriseDaoList[i].job.jid + "' class='jobname'>" + PageHelper.userJobEnterpriseDaoList[i].job.jname + "</a>" +
                "</td>" +
                "<td>" +
                "<div class='company'>" +
                "<a href='company.do?eid=" + PageHelper.userJobEnterpriseDaoList[i].job.enterprise.eid + "'>" + PageHelper.userJobEnterpriseDaoList[i].job.enterprise.ename + "</a>" +
                "</div>" +
                "</td>" +
                "<td></td>" +
                "<td>" + PageHelper.userJobEnterpriseDaoList[i].job.jplace + "</td>" +
                "<td><span>" + PageHelper.userJobEnterpriseDaoList[i].job.jmonthsalary + "</span></td>" +
                "<td>" + difTime + "</td>" +
                "</tr>" +
                "<tr class='xxdetail none'>" +
                "<td colspan='5'>" +
                "<div class='yaoqiu'>学历要求：" + PageHelper.userJobEnterpriseDaoList[i].job.jmineducation +
                " | 工作经验：" + PageHelper.userJobEnterpriseDaoList[i].job.jexperience +
                "| 公司规模：" + PageHelper.userJobEnterpriseDaoList[i].job.jrecruitsbumber +
                "人 | 招聘方式：" + PageHelper.userJobEnterpriseDaoList[i].job.jrecruitmentmethod +
                "<br/>" +
                "岗位职责：" + PageHelper.userJobEnterpriseDaoList[i].job.jresponsibility + "<br/>" +
                "岗位要求：" + PageHelper.userJobEnterpriseDaoList[i].job.jrequirements +
                "</div></td><td>";
            if (PageHelper.userJobEnterpriseDaoList[i].jobuserstatus == 1) {
                obj = obj + "<div id='ApplyDiv' class='applydiv' >" +
                    "<a id='Applya' class='ysqbtn'  href='getOnejobByJid.do?uid=" + uid + "&jid=" + PageHelper.userJobEnterpriseDaoList[i].job.jid + "' >已申请</a>";
            } else {
                obj = obj + "<div id='ApplyDiv' class='applydiv' >" +
                    "<a id='Applya' class='ljsqbtn'  href='getOnejobByJid.do?uid=" + uid + "&jid=" + PageHelper.userJobEnterpriseDaoList[i].job.jid + "'>立即申请</a>"
            }
            if (PageHelper.userJobEnterpriseDaoList[i].jobuserattention == 1) {
                obj = obj + "<span id='jobattentionspan" + PageHelper.userJobEnterpriseDaoList[i].job.jid + "' valus='" + PageHelper.userJobEnterpriseDaoList[i].job.jid + "' class='ygz'>已关注</span>";
            } else {
                obj = obj + "<span id='jobattentionspan" + PageHelper.userJobEnterpriseDaoList[i].job.jid + "' valus='" + PageHelper.userJobEnterpriseDaoList[i].job.jid + "' >关注</span>";
            }
            $(obj).appendTo("tbody")
        }
        $("#headiv").empty()
        $("#footdiv").empty()
        var pagetip = "<span>共" + PageHelper.countnums + "条  第" + PageHelper.nowpage + "/" + PageHelper.countpage + "页</span>"
        $(pagetip).appendTo($("#headiv"))
        $(pagetip).appendTo($("#footdiv"))
        var PageNumber =
            "<a id='HomePage' value='1' class='fy1'>首页</a>" +
            "<a id='PreviousPage'  class='fy1'>上一页</a>";
        for (var i = 1; i <= PageHelper.countpage; i++) {
            if (i == PageHelper.nowpage) {
                PageNumber = PageNumber + "<a id='page'  class='fy2 on'>" + i + "</></a>"
            } else {
                PageNumber = PageNumber + "<a id='page' class='fy2'>" + i + "</a>"
            }
        }
        PageNumber = PageNumber +
            "<a id='NextPage'  class='fy1' >下一页</a>" +
            "<a id='LastPage' value='" + PageHelper.countpage + "' class='fy1'>尾页</a>";
        $(PageNumber).appendTo($("[id='PageBlock']"))
    }

    function pagesearch() {
        $.get("getjobsByKeywordPageHelper.do",
            "uid=${user.uid}" +
            "&keyword=" + keyword +
            "&nowpage=" + nowpage, function (PageHelper) {
                initpagesearch(PageHelper)
            })
    }

    $(document).ready(function () {
        pagesearch()
        $(document).on("click", "[id='page']", function () {
            nowpage = $(this).html()
            pagesearch()
        });
        $(document).on("click", "[id='jobsearchbox']", function () {
            nowpage = 1;
            if ($("[id='keyword']").val() != "") {
                keyword = $("[id='keywords']").val();
            } else {
                keyword = "";
            }
            pagesearch()
        });
        $(document).on("click", "[id='HomePage']", function () {
            nowpage = $("[id='HomePage']").attr("value")
            pagesearch()
        });
        $(document).on("click", "[id='PreviousPage']", function () {
            if (nowpage > 1) {
                nowpage = nowpage - 1;
                pagesearch()
            } else {
                pagesearch()
            }
        });
        $(document).on("click", "[id='LastPage']", function () {
            nowpage = $("[id='LastPage']").attr("value")
            pagesearch()
        });
        $(document).on("click", "[id='NextPage']", function () {
            if (nowpage < $("[id='LastPage']").attr("value")) {
                nowpage = nowpage + 1;
                pagesearch()
            }
        });

        $(document).on("click", "span", function () {
            var spanid = $(this).attr("id")
            var jid = $(this).attr("valus");
            if (jid != undefined) {
                if ("${user.uid}" != "") {
                    $.get("queryUserJobEnterprise.do",
                        {
                            "uid": "${user.uid}",
                            "eid": "${userJobEnterprise.job.enterprise.eid}",
                            "jid": jid
                        },
                        function (obj) {
                            eval("var str=" + obj)
                            if (str == null) {
                                $.get("addUserJobEnterprisewithUser.do",
                                    {
                                        "uid": "${user.uid}",
                                        "eid": "${userJobEnterprise.job.enterprise.eid}",
                                        "jid": jid,
                                        "jobuserattention": 1
                                    }, function (i) {
                                        if (i == 1) {
                                            $("[id='" + spanid + "']").html("已关注")
                                            $("[id='" + spanid + "']").attr("class", "ygz")
                                        }
                                    })
                            } else {
                                if (str.jobuserattention == null || str.jobuserattention == 0) {
                                    $.get("modifyUserJobEnterprise.do",
                                        {
                                            "uid": "${user.uid}",
                                            "eid": "${userJobEnterprise.job.enterprise.eid}",
                                            "jid": jid,
                                            "jobuserattention": 1
                                        },
                                        function (i) {
                                            if (i == 1) {
                                                $("[id='" + spanid + "']").html("已关注")
                                                $("[id='" + spanid + "']").attr("class", "ygz")

                                            }

                                        });
                                } else if (str.jobuserattention == 1) {
                                    $.get("modifyUserJobEnterprise.do",
                                        {
                                            "uid": "${user.uid}",
                                            "eid": "${userJobEnterprise.job.enterprise.eid}",
                                            "jid": jid,
                                            "jobuserattention": 0
                                        },
                                        function (i) {
                                            if (i == 1) {
                                                $("[id='" + spanid + "']").html("关注")
                                                $("[id='" + spanid + "']").removeClass("ygz")

                                            }
                                        })
                                }
                            }
                        })
                } else {
                    var b = window.confirm("您还没有登录，请登录");
                    if (b) {
                        window.location.replace("index.jsp")
                    }
                }
            }

        })


    })

</script>
</html>
